﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core.Lister;
using COFE.Core;
using COFE.Core.Entry;

namespace COFE.Data.Profile
{
    public interface IDBEntryPropertyManager
    {
        /// <summary>
        /// Return all supported properties of the specified entries.
        /// </summary>
        /// <param name="entries"></param>
        /// <returns></returns>
        object[] GetCachedProperties(COFEDB2 context, Entry dbEntry);

        /// <summary>
        /// If cached return the value of the specified property from database, otherwise return null.
        /// </summary>
        /// <param name="entries"></param>
        /// <param name="property"></param>        
        /// <returns></returns>
        object GetProperty(COFEDB2 context, Entry dbEntry, object property);

        /// <summary>
        /// Explicitly set a property.
        /// </summary>
        /// <param name="dbEntry"></param>
        /// <param name="property"></param>
        /// <param name="value"></param>
        void SetProperty(COFEDB2 context, Entry dbEntry, object property, object value);

        bool IsPropertyCachable(object property);

        /// <summary>
        /// Cache only primary properties for an entry.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="dbEntry"></param>
        /// <param name="propProvider"></param>
        void CachePrimaryProperties(COFEDB2 context, Entry dbEntry, IPropertyProvider propProvider);

        /// <summary>
        /// Usually called by IDBEntryManager (in a new thread) to update all secondary properties 
        /// (for primary, use IDBEntryManager.UpdateEntry) to the database.
        /// Noted that only String, Int32, Bool, DateTime and Guid are supported.
        /// </summary>
        void CacheProperties(Guid dbEntryId, IInternalFileSystemInfoExA entry);
    }

}
